package com.example.demo;

import com.example.demo.component.UserComponent;
import com.example.demo.config.User;
import com.example.demo.config.UserConfiguration;
//import com.example.demo.controller.UserController;
import com.example.demo.controller.UserController;
import com.example.demo.controller.UserController2;
import com.example.demo.controller.UserController3;
import com.example.demo.model.UserInfo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringIocApplication {
	public static void main(String[] args) {
		//Controller
		//获取Spring上下文对象
		ApplicationContext context= SpringApplication.run(SpringIocApplication.class, args);
		//从Spring上下文中获取对象
//		UserController userController=context.getBean(UserController.class);
//		//使用对象
//		userController.sayHi();

//		//Service
//		//从Spring上下文中获取对象
//		UserService userService=context.getBean(UserService.class);
//		//使用对象
//		userService.sayHi("ccs");
//
//		//Repository
//		//从Spring上下文中获取对象
//		UserRepository userRepository=context.getBean(UserRepository.class);
//		//使用对象
//		userRepository.sayHi();

//		//Configuration
//		//从Spring上下文中获取对象
//		UserConfiguration configuration=context.getBean(UserConfiguration.class);
//		//使用对象
//		configuration.sayHi();
//
//		//Component
//		UserComponent component=context.getBean(UserComponent.class);
//		userController.sayHi();
//
//		//User
////		User user=context.getBean(User.class);
////		System.out.println(user);
//
//
////		User user1=context.getBean(User.class);
////		System.out.println(user1);
//
//		UserInfo user1=context.getBean("czq",UserInfo.class);
//		System.out.println(user1);
//
//		UserInfo user2=context.getBean("ccs",UserInfo.class);
//		System.out.println(user2);


		//DI 依赖注入

//		UserController userController1=(UserController) context.getBean(UserController.class);
//		userController1.sayHi();
//
//		UserController2 userController2=(UserController2) context.getBean(UserController2.class);
//		userController2.hi();
//
//		UserController3 userController3=(UserController3) context.getBean(UserController3.class);
//		userController3.hi();


	}

}
